package pybaldaj.thrift;

import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;

import pybaldaj.thrift.generated.ThriftDemo;
import pybaldaj.thrift.generated.TimeStamp;

public class MainClient {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		TSocket sock = new TSocket("localhost", 18999);
		TTransport trans = sock;
		TProtocol p = new TBinaryProtocol(trans); 
		
		ThriftDemo.Client client = new ThriftDemo.Client(p); 
		
		try {
	        trans.open();
	        client.reset();
	        TimeStamp t;
	        t = client.get();
	        System.out.println("seq: " + t.sequence + " date:" + new String(t.date.array()));
	        t = client.get();
	        System.out.println("seq: " + t.sequence + " date:" + new String(t.date.array()));
	        client.setIncrement(8);
	        t = client.get();
	        System.out.println("seq: " + t.sequence + " date:" + new String(t.date.array()));
	        client.setIncrement(2);
	        t = client.get();
	        System.out.println("seq: " + t.sequence + " date:" + new String(t.date.array()));
	        client.reset();
	        t = client.get();
	        System.out.println("seq: " + t.sequence + " date:" + new String(t.date.array()));
	        t = client.get();
	        System.out.println("seq: " + t.sequence + " date:" + new String(t.date.array()));
	        
	    } catch (Exception ex) {
	        ex.printStackTrace();
	    }
	}

}
